﻿#region Copyright Notice
// 
// 
// Copyright (c) 2009-2010 Anindya Chatterjee
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// 
// 
// 
#endregion
namespace GCore
{
    /// <example>
    /// <code>
    /// 
    /// using GCore;
    /// using System;
    /// using System.Net;
    /// using System.Collections.Generic;
    /// 
    /// namespace Demo
    /// {
    ///     public class DemoService : GService&lt;DemoFeed, DemoEntry&gt;
    ///     {
    ///         public DemoService(string userName, string password)
    ///             :base(userName, password)
    ///         {   
    ///         }
    ///         
    ///         public DemoService(string userName, string password, WebProxy proxy)
    ///             :base(userName, password, proxy)
    ///         {
    ///         }
    ///         
    ///         public DemoFeed GetAllFeed()
    ///         {
    ///             return base.GetAllFeed();
    ///         }
    ///         
    ///         public DemoEntry SubmitEntry(DemoEntry entry, string appName)
    ///         {
    ///             return base.SubmitNewEntry(entry, appName);
    ///         }
    /// 
    ///         public event SubmitNewEntryCompletedEventHandler&lt;DemoFeed, DemoEntry&gt; SubmitEntryCompleted;
    /// 
    ///         public void SubmitEntryAsync(DemoEntry newEntry, string applicationName, object userState)
    ///         {
    ///             SubmitNewEntryCompleted += DemoServiceSubmitNewEntryCompleted;
    ///             base.SubmitNewEntryAsync(newEntry, applicationName, userState);
    ///         }
    /// 
    ///         public void SubmitEntryAsyncCancel(object userState)
    ///         {
    ///             SubmitNewEntryAsyncCancel(userState);
    ///         }
    /// 
    ///         private void ProjectHostingServiceSubmitNewEntryCompleted(object sender, SubmitNewEntryCompletedEventArgs&lt;DemoFeed, DemoEntry&gt; e)
    ///         {
    ///             if (SubmitEntryCompleted != null)
    ///                 SubmitEntryCompleted(sender, e);
    ///         }
    ///     }
    ///     
    ///     // please put the below XmlRoot attribute to every feed class extending GFeed&lt;TEntry&gt;
    ///     [XmlRoot("feed", Namespace = "http://www.w3.org/2005/Atom")]
    ///     public class DemoFeed : GFeed&lt;DemoEntry&gt;
    ///     {
    ///         public override void Close()
    ///         {
    ///             base.Close();
    ///             // following is a demo schema for the demo service. Each specific schema for a service
    ///             // needed to be add here.
    ///             XmlNamespaceCollection.Add("demo", "http://schemas.google.com/demoservice/demo/2009");
    ///         }
    ///     }
    ///     
    ///     // please add the following XmlRoot attribute in each entry class extending GEntry. 
    ///     [XmlRoot("entry", Namespace = "http://www.w3.org/2005/Atom")]
    ///     public class DemoEntry : GEntry
    ///     {
    ///         [XmlElement("demoid", Namespace = "http://schemas.google.com/demoservice/demo/2009")]
    ///         public string DemoId { get; set; }
    ///         
    ///         [XmlElement("label", Namespace = "http://schemas.google.com/demoservice/demo/2009")]
    ///         public List&lt;string&gt; Labels { get; set; }
    ///         
    ///         public override void Close()
    ///         {
    ///             base.Close();
    ///             // following is a demo schema for the demo service. Each specific schema for a service
    ///             // needed to be add here.
    ///             XmlNamespaceCollection.Add("demo", "http://schemas.google.com/demoservice/demo/2009");
    ///         }
    ///     }
    ///     
    ///     public class Test
    ///     {
    ///         static void Main()
    ///         {
    ///             var service = new DemoService()
    ///                                 {
    ///                                     GUserName = "aguy@gmail.com",
    ///                                     GPassword = "password123",
    ///                                     ProxySettings = new WebProxy("proxy.domain.com", 3128)
    ///                                                         {
    ///                                                             Credentials = new NetworkCredential
    ///                                                                             {
    ///                                                                                 UserName = "username",
    ///                                                                                 Password = "password"
    ///                                                                             }
    ///                                                         }
    ///
    ///                                 };
    ///                                 
    ///             Console.WriteLine("Starting synchronous operation.....");
    ///             DemoFeed resultFeed = service.GetAllFeed();
    ///             Console.WriteLine(resultFeed.Entries.Count);
    ///             
    ///             var newEntry = new DemoEntry()
    ///                             {
    ///                                 DemoId = "id",
    ///                                 Labels = new List&lt;string&gt;(){ "Label" },
    ///                                 Author = new Author
    ///                                             {
    ///                                                 Name = "me"
    ///                                             }
    ///                             };
    ///                             
    ///             DemoEntry resultEntry = service.SubmitEntry(newEntry, "demoapp-1");
    ///             Console.WriteLine(resultEntry.Published.ToString());
    ///             Console.WriteLine("Synchronous operation completed");
    ///             
    ///             Console.WriteLine("Starting asynchronous operation....");
    ///             service.SubmitEntryCompleted += DemoNewEntryCompleted;
    ///             service.SubmitEntryAsync(newEntry, "demoapp-1", null);
    ///             Console.WriteLine("Asynchronous method invokation is completed.");
    ///             Console.ReadLine();
    ///         }
    /// 
    ///         private void DemoNewEntryCompleted(object sender, SubmitNewEntryCompletedEventArgs&lt;DemoFeed, DemoEntry&gt; e)
    ///         {
    ///             Console.WriteLine("Asynchronous event captured.");
    ///             Console.WriteLine(e.Result.Published.ToString());
    ///         }
    ///     }
    /// }
    /// </code>
    /// </example>
    public partial class GService<TFeed, TEntry>
        where TFeed : GFeed<TEntry>, new()
        where TEntry : GEntry, new()
    {
    }
}